package com.azi.baseconhecimento.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

public class RequestCodeScape
{
 
	public static final String CODIGO_NENHUM = "";
	public static final String CODIGO_JAVA = "Java";
	public static final String CODIGO_JAVASCRIPT = "JavaScript";
	public static final String CODIGO_JAVA_PROPERTIES = "Java Properties";
	public static final String CODIGO_SQL = "SQL";
	public static final String CODIGO_ORACLE_SQL = "Oracle SQL";
	public static final String CODIGO_HTML = "HTML";
	public static final String CODIGO_CSS = "CSS";
	public static final String CODIGO_XML = "XML";
	public static final String CODIGO_C = "C";
	public static final String CODIGO_CPP = "C++";
	public static final String CODIGO_CSHARP = "C#";
	public static final String CODIGO_SCALA = "Scala";
	public static final String CODIGO_PYTHON = "Python";
	public static final String CODIGO_PERL = "Pearl";
	public static final String CODIGO_PASCAL = "Pascal";
	public static final String CODIGO_RUBY = "Ruby";
	public static final String CODIGO_FLEX = "Flex";
	public static final String CODIGO_PHP = "PHP";
	public static final String CODIGO_SHELL = "Shell";
	
	private List<String> listInports;
	private String code;
	
	public RequestCodeScape(String code)
	{
		this.code = replaceCodeMarkup(code);
		listInports = createImportList(this.code);
	}
	
	
	private String replaceCodeMarkup(String code)
	{
		code = code.replaceAll("<code:java>", "<pre class='sh_java'>");
		code = code.replaceAll("<code:javascript>", "<pre class='sh_javascript'>");
		code = code.replaceAll("<code:javaproperties>", "<pre class='sh_properties'>");
		code = code.replaceAll("<code:xml>", "<pre class='sh_xml'>");
		code = code.replaceAll("<code:c>", "<pre class='sh_c'>");
		code = code.replaceAll("<code:cpp>", "<pre class='sh_cpp'>");
		code = code.replaceAll("<code:csharp>", "<pre class='sh_csharp'>");
		code = code.replaceAll("<code:scala>", "<pre class='sh_scala'>");
		code = code.replaceAll("<code:python>", "<pre class='sh_python'>");
		code = code.replaceAll("<code:perl>", "<pre class='sh_perl'>");
		code = code.replaceAll("<code:pascal>", "<pre class='sh_pascal'>");
		code = code.replaceAll("<code:ruby>", "<pre class='sh_ruby'>");
		code = code.replaceAll("<code:flex>", "<pre class='sh_flex'>");
		code = code.replaceAll("<code:php>", "<pre class='sh_php'>");
		code = code.replaceAll("<code:shell>", "<pre class='sh_sh'>");
		
		code = code.replaceAll("</code>", "</pre>");
		return code;
	}
	
	private List<String> createImportList(String code)
	{
		List<String> list = new ArrayList<String>();
		
		if(code.contains("class='sh_java'"))
		{

			list.add("sh_java.min.js");
		}
		
		if(code.contains("class='sh_javascript'"))
		{
			list.add("sh_javascript.min.js");
		}
		
		if(code.contains("class='sh_properties'>"))
		{
			list.add("sh_properties.min.js");
		}
		
		if(code.contains("class='sh_xml'"))
		{
			list.add("sh_xml.min.js");
		}
		
		if(code.contains("class='sh_c'"))
		{
			list.add("sh_c.min.js");
		}
		
		if(code.contains("class='sh_cpp'>"))
		{
			list.add("sh_cpp.min.js");
		}
		
		if(code.contains("class='sh_csharp'"))
		{
			list.add("sh_csharp.min.js");
		}
		
		if(code.contains("class='sh_scala'"))
		{
			list.add("sh_scala.min.js");
		}
		
		if(code.contains("class='sh_python'"))
		{
			list.add("sh_python.min.js");
		}
		
		if(code.contains("class='sh_perl'"))
		{
			list.add("sh_perl.min.js");
		}
		
		if(code.contains("class='sh_pascal'"))
		{
			list.add("sh_pascal.min.js");
		}
		
		if(code.contains("class='sh_ruby'"))
		{
			list.add("sh_ruby.min.js");
		}
		
		if(code.contains("class='sh_flex'"))
		{
			list.add("sh_flex.min.js");
		}
		
		if(code.contains("class='sh_php'"))
		{
			list.add("sh_php.min.js");
		}
		
		if(code.contains("class='sh_sh'"))
		{
			list.add("sh_sh.min.js");
		}
		
		return list;
	}

	public List<String> getListInports() {
		return listInports;
	}

	public void setListInports(List<String> listInports) {
		this.listInports = listInports;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
}
